home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 July: Mac OS SDK / Dev.CD Jul 99 SDK1.toast / Development Kits / Mac OS / Interfaces&Libraries / Universal / Interfaces / CIncludes / Fonts.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-08-17  |  11.2 KB  |  429 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        Fonts.h
  3.  
  4.      Contains:    Font Manager Interfaces.
  5.  
  6.      Version:    Technology:    MacOS 8
  7.                  Release:    Universal Interfaces 3.2
  8.  
  9.      Copyright:    © 1985-1998 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:        For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. */
  17. #ifndef __FONTS__
  18. #define __FONTS__
  19.  
  20. #ifndef __MACTYPES__
  21. #include <MacTypes.h>
  22. #endif
  23. #ifndef __QUICKDRAW__
  24. #include <Quickdraw.h>
  25. #endif
  26.  
  27.  
  28.  
  29. #if PRAGMA_ONCE
  30. #pragma once
  31. #endif
  32.  
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36.  
  37. #if PRAGMA_IMPORT
  38. #pragma import on
  39. #endif
  40.  
  41. #if PRAGMA_STRUCT_ALIGN
  42.     #pragma options align=mac68k
  43. #elif PRAGMA_STRUCT_PACKPUSH
  44.     #pragma pack(push, 2)
  45. #elif PRAGMA_STRUCT_PACK
  46.     #pragma pack(2)
  47. #endif
  48.  
  49.  
  50. enum {
  51.     systemFont                    = 0,
  52.     applFont                    = 1
  53. };
  54.  
  55. /* kPlatformDefaultGuiFontID is used in QuickTime 3.0 */
  56. #if TARGET_OS_MAC
  57.  
  58. enum {
  59.     kPlatformDefaultGuiFontID    = applFont
  60. };
  61.  
  62. #else
  63.  
  64. enum {
  65.     kPlatformDefaultGuiFontID    = -1
  66. };
  67.  
  68. #endif  /* TARGET_OS_MAC */
  69.  
  70. /*
  71.     The following font constants are deprecated.  
  72.     Please use GetFNum() to look up the font ID by name.
  73. */
  74.  
  75. enum {
  76.     kFontIDNewYork                = 2,
  77.     kFontIDGeneva                = 3,
  78.     kFontIDMonaco                = 4,
  79.     kFontIDVenice                = 5,
  80.     kFontIDLondon                = 6,
  81.     kFontIDAthens                = 7,
  82.     kFontIDSanFrancisco            = 8,
  83.     kFontIDToronto                = 9,
  84.     kFontIDCairo                = 11,
  85.     kFontIDLosAngeles            = 12,
  86.     kFontIDTimes                = 20,
  87.     kFontIDHelvetica            = 21,
  88.     kFontIDCourier                = 22,
  89.     kFontIDSymbol                = 23,
  90.     kFontIDMobile                = 24
  91. };
  92.  
  93. #if OLDROUTINENAMES
  94.  
  95. enum {
  96.     newYork                        = kFontIDNewYork,
  97.     geneva                        = kFontIDGeneva,
  98.     monaco                        = kFontIDMonaco,
  99.     venice                        = kFontIDVenice,
  100.     london                        = kFontIDLondon,
  101.     athens                        = kFontIDAthens,
  102.     sanFran                        = kFontIDSanFrancisco,
  103.     toronto                        = kFontIDToronto,
  104.     cairo                        = kFontIDCairo,
  105.     losAngeles                    = kFontIDLosAngeles,
  106.     times                        = kFontIDTimes,
  107.     helvetica                    = kFontIDHelvetica,
  108.     courier                        = kFontIDCourier,
  109.     symbol                        = kFontIDSymbol,
  110.     mobile                        = kFontIDMobile
  111. };
  112.  
  113. #endif  /* OLDROUTINENAMES */
  114.  
  115.  
  116. enum {
  117.     commandMark                    = 17,
  118.     checkMark                    = 18,
  119.     diamondMark                    = 19,
  120.     appleMark                    = 20
  121. };
  122.  
  123.  
  124. enum {
  125.     propFont                    = 36864L,
  126.     prpFntH                        = 36865L,
  127.     prpFntW                        = 36866L,
  128.     prpFntHW                    = 36867L,
  129.     fixedFont                    = 45056L,
  130.     fxdFntH                        = 45057L,
  131.     fxdFntW                        = 45058L,
  132.     fxdFntHW                    = 45059L,
  133.     fontWid                        = 44208L
  134. };
  135.  
  136.  
  137. struct FMInput {
  138.     short                             family;
  139.     short                             size;
  140.     Style                             face;
  141.     Boolean                         needBits;
  142.     short                             device;
  143.     Point                             numer;
  144.     Point                             denom;
  145. };
  146. typedef struct FMInput                    FMInput;
  147.  
  148. struct FMOutput {
  149.     short                             errNum;
  150.     Handle                             fontHandle;                    /* the previous "privateFontResult" was a mistake! */
  151.     UInt8                             boldPixels;
  152.     UInt8                             italicPixels;
  153.     UInt8                             ulOffset;
  154.     UInt8                             ulShadow;
  155.     UInt8                             ulThick;
  156.     UInt8                             shadowPixels;
  157.     SInt8                             extra;
  158.     UInt8                             ascent;
  159.     UInt8                             descent;
  160.     UInt8                             widMax;
  161.     SInt8                             leading;
  162.     SInt8                             curStyle;
  163.     Point                             numer;
  164.     Point                             denom;
  165. };
  166. typedef struct FMOutput                    FMOutput;
  167.  
  168. typedef FMOutput *                        FMOutPtr;
  169. typedef FMOutput *                        FMOutputPtr;
  170.  
  171. struct FontRec {
  172.     short                             fontType;                    /*font type*/
  173.     short                             firstChar;                    /*ASCII code of first character*/
  174.     short                             lastChar;                    /*ASCII code of last character*/
  175.     short                             widMax;                        /*maximum character width*/
  176.     short                             kernMax;                    /*negative of maximum character kern*/
  177.     short                             nDescent;                    /*negative of descent*/
  178.     short                             fRectWidth;                    /*width of font rectangle*/
  179.     short                             fRectHeight;                /*height of font rectangle*/
  180.     unsigned short                     owTLoc;                        /*offset to offset/width table*/
  181.     short                             ascent;                        /*ascent*/
  182.     short                             descent;                    /*descent*/
  183.     short                             leading;                    /*leading*/
  184.     short                             rowWords;                    /*row width of bit image / 2 */
  185. };
  186. typedef struct FontRec                    FontRec;
  187. typedef FontRec *                        FontRecPtr;
  188. typedef FontRecPtr *                    FontRecHdl;
  189.  
  190. struct FMetricRec {
  191.     Fixed                             ascent;                        /*base line to top*/
  192.     Fixed                             descent;                    /*base line to bottom*/
  193.     Fixed                             leading;                    /*leading between lines*/
  194.     Fixed                             widMax;                        /*maximum character width*/
  195.     Handle                             wTabHandle;                    /*handle to font width table*/
  196. };
  197. typedef struct FMetricRec                FMetricRec;
  198. /*
  199.    typedef struct FMetricRec FMetricRec, *FMetricRecPtr;
  200.    typedef FMetricRecPtr *FMetricRecHandle;
  201. */
  202. typedef FMetricRec *                    FMetricRecPtr;
  203. typedef FMetricRecPtr *                    FMetricRecHandle;
  204.  
  205. struct WidEntry {
  206.     short                             widStyle;                    /*style entry applies to*/
  207. };
  208. typedef struct WidEntry                    WidEntry;
  209.  
  210. struct WidTable {
  211.     short                             numWidths;                    /*number of entries - 1*/
  212. };
  213. typedef struct WidTable                    WidTable;
  214.  
  215. struct AsscEntry {
  216.     short                             fontSize;
  217.     short                             fontStyle;
  218.     short                             fontID;                        /*font resource ID*/
  219. };
  220. typedef struct AsscEntry                AsscEntry;
  221.  
  222. struct FontAssoc {
  223.     short                             numAssoc;                    /*number of entries - 1*/
  224. };
  225. typedef struct FontAssoc                FontAssoc;
  226.  
  227. struct StyleTable {
  228.     short                             fontClass;
  229.     long                             offset;
  230.     long                             reserved;
  231.     char                             indexes[48];
  232. };
  233. typedef struct StyleTable                StyleTable;
  234.  
  235. struct NameTable {
  236.     short                             stringCount;
  237.     Str255                             baseFontName;
  238. };
  239. typedef struct NameTable                NameTable;
  240.  
  241. struct KernPair {
  242.     char                             kernFirst;                    /*1st character of kerned pair*/
  243.     char                             kernSecond;                    /*2nd character of kerned pair*/
  244.     short                             kernWidth;                    /*kerning in 1pt fixed format*/
  245. };
  246. typedef struct KernPair                    KernPair;
  247.  
  248. struct KernEntry {
  249.     short                             kernStyle;                    /*style the entry applies to*/
  250.     short                             kernLength;                    /*length of this entry*/
  251. };
  252. typedef struct KernEntry                KernEntry;
  253.  
  254. struct KernTable {
  255.     short                             numKerns;                    /*number of kerning entries*/
  256. };
  257. typedef struct KernTable                KernTable;
  258.  
  259. struct WidthTable {
  260.     Fixed                             tabData[256];                /*character widths*/
  261.     Handle                             tabFont;                    /*font record used to build table - the previous FontResult was a mistake!*/
  262.     long                             sExtra;                        /*space extra used for table*/
  263.     long                             style;                        /*extra due to style*/
  264.     short                             fID;                        /*font family ID*/
  265.     short                             fSize;                        /*font size request*/
  266.     short                             face;                        /*style (face) request*/
  267.     short                             device;                        /*device requested*/
  268.     Point                             inNumer;                    /*scale factors requested*/
  269.     Point                             inDenom;                    /*scale factors requested*/
  270.     short                             aFID;                        /*actual font family ID for table*/
  271.     Handle                             fHand;                        /*family record used to build up table*/
  272.     Boolean                         usedFam;                    /*used fixed point family widths*/
  273.     UInt8                             aFace;                        /*actual face produced*/
  274.     short                             vOutput;                    /*vertical scale output value*/
  275.     short                             hOutput;                    /*horizontal scale output value*/
  276.     short                             vFactor;                    /*vertical scale output value*/
  277.     short                             hFactor;                    /*horizontal scale output value*/
  278.     short                             aSize;                        /*actual size of actual font used*/
  279.     short                             tabSize;                    /*total size of table*/
  280. };
  281. typedef struct WidthTable                WidthTable;
  282. typedef WidthTable *                    WidthTablePtr;
  283. typedef WidthTablePtr *                    WidthTableHdl;
  284.  
  285.  
  286. struct FamRec {
  287.     short                             ffFlags;                    /*flags for family*/
  288.     short                             ffFamID;                    /*family ID number*/
  289.     short                             ffFirstChar;                /*ASCII code of 1st character*/
  290.     short                             ffLastChar;                    /*ASCII code of last character*/
  291.     short                             ffAscent;                    /*maximum ascent for 1pt font*/
  292.     short                             ffDescent;                    /*maximum descent for 1pt font*/
  293.     short                             ffLeading;                    /*maximum leading for 1pt font*/
  294.     short                             ffWidMax;                    /*maximum widMax for 1pt font*/
  295.     long                             ffWTabOff;                    /*offset to width table*/
  296.     long                             ffKernOff;                    /*offset to kerning table*/
  297.     long                             ffStylOff;                    /*offset to style mapping table*/
  298.     short                             ffProperty[9];                /*style property info*/
  299.     short                             ffIntl[2];                    /*for international use*/
  300.     short                             ffVersion;                    /*version number*/
  301. };
  302. typedef struct FamRec                    FamRec;
  303.  
  304. typedef SInt16                             FontPointSize;
  305. typedef SInt16                             FontFamilyID;
  306. EXTERN_API( void )
  307. InitFonts                        (void)                                                        ONEWORDINLINE(0xA8FE);
  308.  
  309. EXTERN_API( void )
  310. GetFontName                        (short                     familyID,
  311.                                  Str255                 name)                                ONEWORDINLINE(0xA8FF);
  312.  
  313. EXTERN_API( void )
  314. GetFNum                            (ConstStr255Param         name,
  315.                                  short *                familyID)                            ONEWORDINLINE(0xA900);
  316.  
  317. EXTERN_API( Boolean )
  318. RealFont                        (short                     fontNum,
  319.                                  short                     size)                                ONEWORDINLINE(0xA902);
  320.  
  321. EXTERN_API( void )
  322. SetFontLock                        (Boolean                 lockFlag)                            ONEWORDINLINE(0xA903);
  323.  
  324. EXTERN_API( FMOutPtr )
  325. FMSwapFont                        (const FMInput *        inRec)                                ONEWORDINLINE(0xA901);
  326.  
  327. EXTERN_API( void )
  328. SetFScaleDisable                (Boolean                 fscaleDisable)                        ONEWORDINLINE(0xA834);
  329.  
  330. EXTERN_API( void )
  331. FontMetrics                        (FMetricRecPtr             theMetrics)                            ONEWORDINLINE(0xA835);
  332.  
  333. EXTERN_API( void )
  334. SetFractEnable                    (Boolean                 fractEnable)                        ONEWORDINLINE(0xA814);
  335.  
  336. EXTERN_API( short )
  337. GetDefFontSize                    (void)                                                        FIVEWORDINLINE(0x3EB8, 0x0BA8, 0x6604, 0x3EBC, 0x000C);
  338.  
  339. EXTERN_API( Boolean )
  340. IsOutline                        (Point                     numer,
  341.                                  Point                     denom)                                TWOWORDINLINE(0x7000, 0xA854);
  342.  
  343. EXTERN_API( void )
  344. SetOutlinePreferred                (Boolean                 outlinePreferred)                    TWOWORDINLINE(0x7001, 0xA854);
  345.  
  346. EXTERN_API( Boolean )
  347. GetOutlinePreferred                (void)                                                        TWOWORDINLINE(0x7009, 0xA854);
  348.  
  349. EXTERN_API( OSErr )
  350. OutlineMetrics                    (short                     byteCount,
  351.                                  const void *            textPtr,
  352.                                  Point                     numer,
  353.                                  Point                     denom,
  354.                                  short *                yMax,
  355.                                  short *                yMin,
  356.                                  FixedPtr                 awArray,
  357.                                  FixedPtr                 lsbArray,
  358.                                  RectPtr                 boundsArray)                        TWOWORDINLINE(0x7008, 0xA854);
  359.  
  360. EXTERN_API( void )
  361. SetPreserveGlyph                (Boolean                 preserveGlyph)                        TWOWORDINLINE(0x700A, 0xA854);
  362.  
  363. EXTERN_API( Boolean )
  364. GetPreserveGlyph                (void)                                                        TWOWORDINLINE(0x700B, 0xA854);
  365.  
  366. EXTERN_API( OSErr )
  367. FlushFonts                        (void)                                                        TWOWORDINLINE(0x700C, 0xA854);
  368.  
  369. #if CGLUESUPPORTED
  370. EXTERN_API_C( void )
  371. getfnum                            (const char *            theName,
  372.                                  short *                familyID);
  373.  
  374. EXTERN_API_C( void )
  375. getfontname                        (short                     familyID,
  376.                                  char *                    theName);
  377.  
  378. #endif  /* CGLUESUPPORTED */
  379.  
  380. EXTERN_API( short )
  381. GetSysFont                        (void)                                                        TWOWORDINLINE(0x3EB8, 0x0BA6);
  382.  
  383. EXTERN_API( short )
  384. GetAppFont                        (void)                                                        TWOWORDINLINE(0x3EB8, 0x0984);
  385.  
  386. /*---------------------------------------------------------------------------------*/
  387. EXTERN_API( OSStatus )
  388. SetAntiAliasedTextEnabled        (Boolean                 inEnable,
  389.                                  SInt16                 inMinFontSize);
  390.  
  391. EXTERN_API( Boolean )
  392. IsAntiAliasedTextEnabled        (SInt16 *                outMinFontSize);
  393.  
  394. /*---------------------------------------------------------------------------------*/
  395. EXTERN_API( void )
  396. QDTextBounds                    (short                     byteCount,
  397.                                  const void *            textAddr,
  398.                                  Rect *                    bounds);
  399.  
  400. EXTERN_API( OSErr )
  401. FetchFontInfo                    (SInt16                 fontID,
  402.                                  SInt16                 fontSize,
  403.                                  SInt16                 fontStyle,
  404.                                  FontInfo *                info);
  405.  
  406. /*---------------------------------------------------------------------------------*/
  407.  
  408.  
  409. #if PRAGMA_STRUCT_ALIGN
  410.     #pragma options align=reset
  411. #elif PRAGMA_STRUCT_PACKPUSH
  412.     #pragma pack(pop)
  413. #elif PRAGMA_STRUCT_PACK
  414.     #pragma pack()
  415. #endif
  416.  
  417. #ifdef PRAGMA_IMPORT_OFF
  418. #pragma import off
  419. #elif PRAGMA_IMPORT
  420. #pragma import reset
  421. #endif
  422.  
  423. #ifdef __cplusplus
  424. }
  425. #endif
  426.  
  427. #endif /* __FONTS__ */
  428.  
  429.